package com.yuw.hw20190214;

public class HourlyEmployee extends ColaEmployee {
    // 成员变量
    // 时薪
    private double hourlySalary;
    // 工作小时数
    private double monthHours;
    // 行为方法

    // 此处使用了多态：子类重写了父类的同名方法
    @Override
    public double getSalary(int month) {
        // 计算时薪员工工资
        double mySalary = hourlySalary*monthHours;
        // 超出部分工资
        if(monthHours >160){
            mySalary +=(monthHours - 160)*0.5*hourlySalary;
        }
        // 计算有没有生日金
        mySalary += super.getSalary(month);
        return mySalary;
    }

    public HourlyEmployee(String empName, int empBirthdayMonth, double hourlySalary, double monthHours) {
        super(empName, empBirthdayMonth);
        this.hourlySalary = hourlySalary;
        this.monthHours = monthHours;
    }

    public HourlyEmployee() {
    }

    public double getHourlySalary() {
        return hourlySalary;
    }

    public void setHourlySalary(double hourlySalary) {
        this.hourlySalary = hourlySalary;
    }

    public double getMonthHours() {
        return monthHours;
    }

    public void setMonthHours(double monthHours) {
        this.monthHours = monthHours;
    }
}
